<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>用户管理</title>
    <link rel="stylesheet" type="text/css" href="${s.base}/lib/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/lib/dtree/dtree.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/lib/dtree/font/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/css/base/index.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/css/base/theme/theme.css"/>
</head>
<body>
<div class="wrap-container clearfix">
    <div class="column-content-detail">
        <form class="layui-form" method="post" action="/sysUser/exportExecl">
            <div class="search-cont clearfix" id="tool">
                <div class="operation-btn-cont">
                    <div class="operright cyt-retract-close hideMenu">收起筛选<i class="iconfont">&#xe658;</i></div>
                    <div class="operright cyt-retract-open showMenu" style="display: none;">展开筛选<i class="iconfont">&#xe936;</i></div>
                    <@shiro.hasPermission name="sys:sysUser:add">
                    <button class="layui-btn layui-btn-normal layui-btn-mid " type="button" data-tab-name="用户添加"  id="baseUserAddOrEdit" ><i class="iconfont marr5">&#xe65e;</i>添加</button>
                    </@shiro.hasPermission>
                    <@shiro.hasPermission name="sys:sysUser:del">
                    <button class="layui-btn layui-btn-normal layui-btn-mid deleteBtn" type="button" data-url="/sysUser/removeByIds"><i class="iconfont marr5">&#xe6a3;</i>删除</button>
                    </@shiro.hasPermission>
                    <@shiro.hasPermission name="sys:sysUser:export">
                    <button class="layui-btn layui-btn-normal layui-btn-mid" type="submit"><i class="iconfont marr5">&#xe614;</i>导出</button>
                    </@shiro.hasPermission>
                    <div class="triangle-bottom"></div>
                    <div class="triangle-top"></div>
                </div>
                <div class="search-details">
                    <div class="layui-form-item marb5">
                        <div class="layui-inline">
                            <label class="layui-form-label w75">登录名称：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="loginName" id="loginName" placeholder="请输入登录名称" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label w75">用户名称：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="name" id="name" placeholder="请输入用户名称" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label w75">状态：</label>
                            <div class="layui-input-inline">
                                <select name="status" id="status"></select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label w75">用户类型：</label>
                            <div class="layui-input-inline">
                                <select name="userType" id="userType"></select>
                            </div>
                        </div>
                        <div class="layui-inline marl8">
                            <button class="layui-btn layui-btn-normal" type="button" lay-submit="" lay-filter="seacherBtn">搜索</button>
                            <button class="layui-btn layui-btn-normal" type="reset">重置</button>
                        </div>
                    </div>
                </div>
            </div>
        </form>
        <div class="layui-form" id="table-list">
            <table id="entityList" lay-filter="entityList" class="cy-list-table"></table>
        </div>
    </div>
</div>
<!--操作-->
<script type="text/html" id="entityBar">
    <@shiro.hasPermission name="sys:sysUser:edit">
    <a class="layui-btn layui-btn-radius layui-btn-primary layui-btn-sm layui-smbtn-green"  lay-event="edit">编辑</a>
    </@shiro.hasPermission>
    <@shiro.hasPermission name="sys:sysUser:del">
    <button class="layui-btn layui-btn-radius layui-btn-primary layui-btn-sm layui-smbtn-red" lay-event="del">删除</button>
    </@shiro.hasPermission>
</script>
<script src="${s.base}/lib/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="${s.base}/js/common.js" type="text/javascript" charset="utf-8"></script>
<script>
    layui.use(['jquery', 'table', 'page', 'form', 'dtreeUtil'], function () {
        var $ = layui.jquery,
            page = layui.page,
            table = layui.table;
        var tableIns = null;

        page.initDict("base_status,sys_user_type", function (dictData) {
            page.showDict($("#status"), page.aceeptDictContentList(dictData, "base_status"), "全部");
            page.showDict($("#userType"), page.aceeptDictContentList(dictData, "sys_user_type"), "全部");
            var url = "/sysUser/page";
            var cols = [
                {type: 'checkbox', fixed: 'left'},
                {type: 'numbers', title: '序号', width: 50},
                {field: 'loginName', title: '登录名称', width: 200, align: 'center'},
                {field: 'name', title: '用户名称', align: 'center'},
                {
                    field: 'status', title: '状态', width: 150, align: 'center', templet: function (d) {
                        if (d.status === "1") {
                            return '<span class="status-green">' + page.aceeptDictContentName(dictData, "base_status", d.status) + '</span>';
                        } else {
                            return '<span class="status-grey">' + page.aceeptDictContentName(dictData, "base_status", d.status) + '</span>';
                        }
                    }
                },
                {
                    field: 'userType', title: '用户类型', width: 150, align: 'center', templet: function (d) {
                        return page.aceeptDictContentName(dictData, "sys_user_type", d.userType);

                    }
                },
                {
                    field: 'baseUserName', title: '角色', width: 150, align: 'center', templet: function (d) {
                        var s = "";
                        var list = d.roleName.split(",");
                        for (var i = 0; i < list.length; i++) {
                            s += '<a class="layui-btn  layui-btn-xs layui-btn-danger">' + list[i] + '</a>'
                        }
                        return s;
                    }
                },
                {field: 'phone', title: '手机号', width: 150, align: 'center'},
                {
                    field: 'createTime', title: '创建时间', align: 'center', width: 170, templet: function (d) {
                        return new Date(d.createTime).Format("yyyy-MM-dd hh:mm:ss");
                    }
                },
                {title: '操作', width: 170, templet: '#entityBar', align: "center"}
            ];
            tableIns = page.initDate(cols, url);
        });

        //监听行工具事件
        table.on('tool(entityList)', function (obj) {
            var layEvent = obj.event,
                data = obj.data;
            if (layEvent === 'edit') { //编辑
                page.editPopup("/sysUser/getAddOrEdit?id=" + data.id, "用户编辑", "1000px", "700px");
            } else if (layEvent === 'del') { //删除
                page.delete("/sysUser/removeByIds", {"id": data.id, "_method": "DELETE"}, "确定删除该用户吗？", function () {
                    tableIns.reload();
                });
            }
        });

        $("#baseUserAddOrEdit").bind("click", function () {
            page.editPopup("/sysUser/getAddOrEdit", "角户添加", "1000px", "700px");
        });
    });
</script>
</body>
</html>